# -*- coding: utf-8 -*
import requests



def postDiscuzBBs(subject,content,pinglunList, fid, username, url):
    # 格式化评论楼层
    for i in pinglunList:
        content = f'{content}|||{i}'

    # subject=年后发阿凡达案发时发放&message=年后发阿凡达案发时发放&fid=57&username=怎么样评测
    form = {
        'subject': f'{subject}'.encode('gbk',errors='ignore'),
        'message': f'{content}'.encode('gbk',errors='ignore'),
        'fid': f'{fid}',
        'username': f'{username}'.encode('gbk',errors='ignore'),
    }
    html = requests.post(url, data=form)
    if html.text == '发布成功':
        return True
    else:
        return False





if __name__ == '__main__':
    subject = '你好，我是标题'   #标题
    message = '你好，我是内容'   #内容
    fid = '57'                  #板块编号
    username = '怎么样评测'     #发帖用户名
    pinglunList = ['我的评论','我的评论']   #评论楼层

    #格式化评论楼层
    for i in pinglunList:
        message = f'{message}|||{i}'

    print(postDiscuzBBs(subject,message,fid,username))